<!DOCTYPE html>
<html>	
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style.css" rel="stylesheet" type="text/css">
<script language="JavaScript">
	   var HttPRequest = false;

	   function doCallAjax() {
		  HttPRequest = false;
		  if (window.XMLHttpRequest) { // Mozilla, Safari,...
			 HttPRequest = new XMLHttpRequest();
			 if (HttPRequest.overrideMimeType) {
				HttPRequest.overrideMimeType('text/html');
			 }
		  } else if (window.ActiveXObject) { // IE
			 try {
				HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
			 } catch (e) {
				try {
				   HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			 }
		  } 
		  
		  if (!HttPRequest) {
			 alert('Cannot create XMLHTTP instance');
			 return false;
		  }
	
		  var url = 'loginform2.php';
		  var pmeters = "tUsername=" + encodeURI( document.getElementById("txtUsername").value) +
						"&tPassword=" + encodeURI( document.getElementById("txtPassword").value );

			HttPRequest.open('POST',url,true);

			HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			HttPRequest.setRequestHeader("Content-length", pmeters.length);
			HttPRequest.setRequestHeader("Connection", "close");
			HttPRequest.send(pmeters);
			
			
			HttPRequest.onreadystatechange = function()
			{

				if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("mySpan").innerHTML = "Now is Loading...";
				}

				if(HttPRequest.readyState == 4) // Return Request
				{
					if(HttPRequest.responseText == 'Y')
					{
						window.location = 'dashboard.php';
					}
					else
					{
						document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
					}
				}
				
			}

	   }
	</script>
</head>
<body>
 <div id="header">
 	<div class="title">ADMIN LOGIN</div>
 </div>
 <div id="container">
 	<div class="loginform">
 	<form name="frmMain">
 		<span id="mySpan"></span>
 		<div class="login_result" id="login_result" style="display:block;width:100%;text-align:center;height:25px;"></div><br>
	 	<div class="usr">username : <input type="text" name="txtUsername" id="txtUsername" /></div>
	 	<div class="pwd">password : <input type="password" name="txtPassword" id="txtPassword" /></div>
	 	<div class="btn-login"><input name="btnLogin" type="button" id="btnLogin" OnClick="JavaScript:doCallAjax();" value="Login"></div>
	 	
	</form>
 	</div>
 </div>
</body>
</html>